package com.wantdo.web;

import com.wantdo.entity.UserExample;
import com.wantdo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;
import java.util.Map;

/**
 * Created by king on 2017/10/13.
 */
@Controller
public class UserControl {

	@Autowired
	private UserMapper userMapper;

	@ResponseBody
	@RequestMapping("/user/list")
	public Object userList() {
		return userMapper.selectByExample(new UserExample());
	}

	@GetMapping("/hello")
	public String welcome(Map<String, Object> model) {
		model.put("time", new Date());
		model.put("message", "afdsgadkgf");
		System.out.println("hello page");
		return "hello";
	}

	/**
	 * 响应到JSP页面page1
	 *
	 * @return
	 * @author SHANHY
	 * @create  2016年1月5日
	 */
	@RequestMapping("/page1")
	public ModelAndView page1(){
		// 页面位置 /WEB-INF/jsp/page/page.jsp
		ModelAndView mav = new ModelAndView("hello");
		mav.addObject("content", "jkhadfgdaffg");
		return mav;
	}

}
